package com.zhl.thread.cacheline;

/**
 * @program: demos
 * @description:
 * @author: 刘振华
 * @create: 2020-10-13 17:06
 **/
public class StepTest {
	public static int a,b,x,y;
	public static void main(String[] args)throws Exception {
		int i = 0;
		for(;;i++) {
			a=0;b=0;
			x = 1;y = 1;
			Thread one = new Thread(new Runnable() {
				@Override
				public void run() {
					a = 2;
					x = a;
				}
			});
			Thread other = new Thread(new Runnable() {
				@Override
				public void run() {
					b = 2;
					x = b;
				}
			});
			one.start();
			other.start();
			one.join();
			other.join();
			if(x == 0 && y == 0){
				System.out.println("第"+i+"次");
				break;
			}
		}
	}
}
